var { getLoginedUser, fnLoading, fnHideLoading, fnSuccess, fnFail } = require('../../utils/index')
import { domainStatic } from '../../utils/env.js';
import _ from '../../utils/underscore.js';
import { get, fnChoose, lsGetStr, fnUpload, post } from '../../utils/request.js';
// pages/withdraw/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
price:"",
apy:""
  },
  ask:function(){
    let that=this;
     if (that.data.apy>that.data.price){
       fnFail("超过可提现金额");
      setTimeout(function () {
        fnHideLoading()
      }, 1500)
      return;
    }else if(that.data.apy.length==0){
       fnFail("请输入金额");
      setTimeout(function () {
        fnHideLoading()
      }, 1500)
      return;
     }else if(that.data.apy==0){
       fnFail("输入金额不正确");
       setTimeout(function () {
         fnHideLoading()
       }, 1500)
       return;
     }
     else if (that.data.apy <= that.data.price) {
       get({
         path: "/user/commission/withdraw?cash=" + that.data.apy
       }).then(function (res) {
         wx.navigateTo({
           url: '../commission/index?cash=' + that.data.apy,
         })
         console.log(res);
       })

     }
  },
  withdraw:function(){
    let that=this;
    var aply=that.data.price;
    console.log(aply);
    that.setData({
      apy:aply
    })
  },
  aply:function(e){
    let that=this;
    that.setData({
      apy:e.detail.value,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    console.log(options);
    that.setData({
      price: options.type,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})